package com.dudu.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;

import com.dudu.bean.CallStatusBean;
import com.dudu.bean.MenuBean;
import com.dudu.dao.CallStatusDao;
import com.dudu.model.CallStatus;
import com.dudu.model.Menu;
import com.dudu.service.ICallStatusService;

import core.CoreDao;
import core.CoreDaoInvoke;
/**
 * 通话状态service
 * @author gaoxs
 *
 */
public class CallStatusServiceImpl implements ICallStatusService {
	private static final Logger log =  core.util.Logger.getLogger(CallStatusServiceImpl.class.getSimpleName());
	//持久层操作类
	private CallStatusDao callStatusDao = new CallStatusDao();
	private CoreDao coreDao=CoreDaoInvoke.getInstance();
	/**
	 * 查询所有CallStatus信息
	 * @param dao
	 * @param pageSql
	 * @param paramSql
	 * @return
	 */
	public List<CallStatusBean> queryAll(String pageSql,String paramSql) {
		List<CallStatusBean> resultlist=new ArrayList<CallStatusBean>();
		List<CallStatus> list=callStatusDao.queryAllCall(coreDao, pageSql, paramSql);
		for(CallStatus bean:list){
			resultlist.add(conversion(bean));
		}
		return resultlist;
	}
	/**
	 * 查询所有CallStatus信息数量
	 * @param paramSql
	 * @return 数量
	 */
	public int getTotalCall( String paramSql){
		return callStatusDao.getTotalCall(coreDao, paramSql);
	}
	/**
	 * 转化
	 * @param bean
	 * @return
	 */
	private CallStatusBean conversion(CallStatus bean){
		CallStatusBean newBean=new CallStatusBean();
		BeanUtils.copyProperties(bean, newBean);//源,目的
		//PropertyUtils.copyProperties(dest, orig);//目的,源
		return newBean;
	}
	/**
	 * 转化
	 * @param bean
	 * @return
	 */
	private CallStatus conversion(CallStatusBean bean){
		CallStatus newbean=new CallStatus();
		BeanUtils.copyProperties(bean,newbean);//源,目的
		//PropertyUtils.copyProperties(dest, orig);//目的,源
		return newbean;
	}
}
